.. _ocablockfactory: 1.1.4 OcaBlockFactory ====================== Class Hierarchy: :ref:`OcaRoot ` :raw:html:`→` :ref:`OcaWorker ` :raw:html:`→` :ref:`OcaBlockFactory ` .. cpp:class:: OcaBlockFactory: OcaWorker Factory to create custom block instances. Used only in reconfigurable devices. The idea is that you instantiate a factory once, populate it with proto-objects and proto-signal paths, then use it subsequently to instantiate identical blocks. In this context, **proto-object** means a prototype of a block member. Unbound objects are identified by **proto-object numbers (PONo's)** instead of actual object numbers. PONos are unique within the factory, and are converted to globally unique object numbers ONos) in all new block instances that the factory builds. Correspondingly, **proto-signal path** means a signal path expressed in terms of **PONos** rather than **ONos** . When the factory constructs a block, it converts all of its unbound signal paths to normal (bound) signal paths by mapping its **PONos** into **ONos** . The factory also holds a list of **proto-blockports** which are **OcaPorts** that are allocated to new blocks the factory builds. As well, the proto-objects in the factory may contain lists of their own proto-ports. Together, the factory's proto-ports and its members' proto-ports are used to define the factory's set of proto-signal paths. Factories may be predefined at time of device manufacture, or constructed "on the fly" by controllers. To **create a factory** , the controller calls a block's **CreateMember(...)** method with the **ClassID** of this class ( **OcaBlockFactory** ). Factories ignore which block creates them, so it makes no difference which block's **CreateMember(...)** method is used. It will usually make the most sense to use the Root Block's method. To add proto-objects, proto-ports, and proto-signal paths to a block factory, the controller calls the factory's **DefineProtoMember(...), DefineProtoPort(...), and DefineProtoSignalPath(...** ) methods, respectively. **Properties**: .. _ocablockfactory_classid: .. cpp:member:: static const OcaClassID ClassID = "1.1.4" This property is an override of the **OcaRoot** property. This property has id ``3.1``. .. _ocablockfactory_classversion: .. cpp:member:: static const OcaClassVersionNumber ClassVersion = 2 Identifies the interface version of the class. Any change to the class definition leads to a higher class version. This property is an override of the **OcaRoot** property. This property has id ``3.2``. .. _ocablockfactory_protoports: .. cpp:member:: OcaList ProtoPorts List of proto-ports for built objects. The factory itself has no ports. This property has id ``3.1``. .. _ocablockfactory_protomembers: .. cpp:member:: OcaList ProtoMembers List of prot-object identifiers of proto-members in the block. This property has id ``3.2``. .. _ocablockfactory_protosignalpaths: .. cpp:member:: OcaMap ProtoSignalPaths List of proto-signal paths in the block. This property has id ``3.3``. .. _ocablockfactory_globaltype: .. cpp:member:: OcaGlobalTypeIdentifier GlobalType Global block type identifier for reusable blocks. **Added in version 2 of this class.** This property has id ``3.4``. Properties inherited from :ref:`OcaWorker `: - :cpp:texpr:`OcaBoolean` :ref:`OcaWorker::Enabled ` - :cpp:texpr:`OcaList` :ref:`OcaWorker::Ports ` - :cpp:texpr:`OcaString` :ref:`OcaWorker::Label ` - :cpp:texpr:`OcaONo` :ref:`OcaWorker::Owner ` - :cpp:texpr:`OcaTimeInterval` :ref:`OcaWorker::Latency ` Properties inherited from :ref:`OcaRoot `: - :cpp:texpr:`OcaONo` :ref:`OcaRoot::ObjectNumber ` - :cpp:texpr:`OcaBoolean` :ref:`OcaRoot::Lockable ` - :cpp:texpr:`OcaString` :ref:`OcaRoot::Role ` **Methods**: .. _ocablockfactory_defineprotoport: .. cpp:function:: OcaStatus DefineProtoPort(OcaString name, OcaPortMode portmode, OcaProtoPortID &id) Defines a proto-port in the factory. If proto-port already exists, it is replaced with the one from this call. The return value indicates whether the proto-port was successfully added. This method has id ``3.1``. :param OcaString name: Input parameter. :param OcaPortMode portmode: Input parameter. :param OcaProtoPortID id: Output parameter. .. _ocablockfactory_undefineprotoport: .. cpp:function:: OcaStatus UndefineProtoPort(OcaProtoPortID ProtoPortID) Deletes a proto-port from the factory. The return value indicates whether the proto-port was successfully deleted. This method has id ``3.2``. :param OcaProtoPortID ProtoPortID: Input parameter. .. _ocablockfactory_getprotoports: .. cpp:function:: OcaStatus GetProtoPorts(OcaList &Ports) Gets the factory's list of proto-ports. The return value indicates whether the list was successfully retrieved. This method has id ``3.3``. :param OcaList Ports: Output parameter. .. _ocablockfactory_defineprotomember: .. cpp:function:: OcaStatus DefineProtoMember(OcaClassID ClassIdentification, ConstructionParameterDataType ConstructionParameters, OcaProtoONo &ProtoObjectNumber) Defines a proto-member of the given class in the factory. The most current version of the class is used. The return value indicates whether the proto-member was successfully defined. This method has id ``3.4``. :param OcaClassID ClassIdentification: Input parameter. :param ConstructionParameterDataType ConstructionParameters: Input parameter. :param OcaProtoONo ProtoObjectNumber: Output parameter. .. _ocablockfactory_defineprotomemberusingfactory: .. cpp:function:: OcaStatus DefineProtoMemberUsingFactory(OcaONo FactoryONo, OcaProtoONo &ProtoObjectNumber) Defines a proto-member which will be instantiated by a specified factory when the block is built. The return value indicates whether the proto-member was successfully defined. This method has id ``3.5``. :param OcaONo FactoryONo: Input parameter. :param OcaProtoONo ProtoObjectNumber: Output parameter. .. _ocablockfactory_undefineprotomember: .. cpp:function:: OcaStatus UndefineProtoMember(OcaProtoONo ProtoObjectNumber) Deletes a proto-member from the factory. Deletes all proto-signal paths attached to its ports. The return value indicates whether the member was successfully deleted. This method has id ``3.6``. :param OcaProtoONo ProtoObjectNumber: Input parameter. .. _ocablockfactory_getprotomembers: .. cpp:function:: OcaStatus GetProtoMembers(OcaList &Members) Gets the factory's list of proto-members. Does not recurse inner proto-blocks. The return value indicates whether the list was successfully retrieved. This method has id ``3.7``. :param OcaList Members: Output parameter. .. _ocablockfactory_defineprotosignalpath: .. cpp:function:: OcaStatus DefineProtoSignalPath(OcaProtoSignalPath Path, OcaUint16 &Index) Defines a proto-signal path in the factory. The return value indicates whether the proto-signal path was successfully defined. This method has id ``3.8``. :param OcaProtoSignalPath Path: Input parameter. :param OcaUint16 Index: Output parameter. .. _ocablockfactory_undefineprotosignalpath: .. cpp:function:: OcaStatus UndefineProtoSignalPath(OcaUint16 &Index) Deletes a proto-signal path from the factory. The return value indicates whether the signal path was successfully added. This method has id ``3.9``. :param OcaUint16 Index: Output parameter. .. _ocablockfactory_getprotosignalpaths: .. cpp:function:: OcaStatus GetProtoSignalPaths(OcaMap &Members) Gets the factory's list of proto-signal paths. Map key is proto-signal path ID. Does not recurse inner proto-blocks. The return value indicates whether the list was successfully retrieved. This method has id ``3.10``. :param OcaMap Members: Output parameter. .. _ocablockfactory_getglobaltype: .. cpp:function:: OcaStatus GetGlobalType(OcaGlobalTypeIdentifier &GlobalType) Gets the global type identifier for blocks created by this factory. The return value indicates whether the identifier was successfully retrieved. **Added in version 2 of this class.** This method has id ``3.11``. :param OcaGlobalTypeIdentifier GlobalType: Output parameter. .. _ocablockfactory_setglobaltype: .. cpp:function:: OcaStatus SetGlobalType(OcaGlobalTypeIdentifier GlobalType) Sets the global type identifier for blocks created by this factory. The return value indicates whether the identifier was successfully set. **Added in version 2 of this class.** This method has id ``3.12``. :param OcaGlobalTypeIdentifier GlobalType: Input parameter. Methods inherited from :ref:`OcaWorker `: - :ref:`OcaWorker::GetEnabled(enabled) ` - :ref:`OcaWorker::SetEnabled(enabled) ` - :ref:`OcaWorker::AddPort(Label, Mode, ID) ` - :ref:`OcaWorker::DeletePort(ID) ` - :ref:`OcaWorker::GetPorts(OcaPorts) ` - :ref:`OcaWorker::GetPortName(PortID, Name) ` - :ref:`OcaWorker::SetPortName(PortID, Name) ` - :ref:`OcaWorker::GetLabel(label) ` - :ref:`OcaWorker::SetLabel(label) ` - :ref:`OcaWorker::GetOwner(owner) ` - :ref:`OcaWorker::GetLatency(latency) ` - :ref:`OcaWorker::SetLatency(latency) ` - :ref:`OcaWorker::GetPath(NamePath, ONoPath) ` Methods inherited from :ref:`OcaRoot `: - :ref:`OcaRoot::GetClassIdentification(ClassIdentification) ` - :ref:`OcaRoot::GetLockable(lockable) ` - :ref:`OcaRoot::LockTotal() ` - :ref:`OcaRoot::Unlock() ` - :ref:`OcaRoot::GetRole(Role) ` - :ref:`OcaRoot::LockReadonly() `